<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Registration extends CI_Controller {
	public function __construct()
	 {
	  parent::__construct();
	  $this->load->model('user','',TRUE);
	 }
	function index()
	{
	$this->load->library('form_validation');

    $this->form_validation->set_rules('username', 'User Name', 'trim|required|min_length[4]|xss_clean');
    $this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[4]|xss_clean');
    $this->form_validation->set_rules('emaila_ddress','Your Email','trim|requred|valid_email|xss_clean');
    $this->form_validation->set_rules('con_password', 'Password Confirmation', 'trim|required|matches[password]');
	
    if($this->form_validation->run() == FALSE)
    {
      $this->load->view('registration_view');
    }
    else
    {
      //add user
      $this->user->add_user();
      $data ["msg"]= "Thak you for registering, you can login now!";
   	  $this->load->view('login_view',$data);
    }
	}
}



?>